package com.shengzai.mapreduce.scorecount;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class ReduceScoreCount extends Reducer<Text,Text,Text, IntWritable> {
    @Override
    protected void reduce(Text key, Iterable<Text> values, Reducer<Text, Text, Text, IntWritable>.Context context) throws IOException, InterruptedException {
        int allScore = 0;
        for (Text value : values) {
            int i = Integer.parseInt(value.toString());
            allScore+=i;
        }
        context.write(key,new IntWritable(allScore));
    }
}
